package com.nanhai.buddhist.college.module.collegebase.dal.mysql.rewardpunishrecord;

import java.util.*;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.classes.ClassesDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.colleges.CollegesDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.rewardpunishrecord.RewardPunishRecordDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.studentroll.StudentRollDO;
import org.apache.ibatis.annotations.Mapper;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.rewardpunishrecord.vo.*;

/**
 * 奖罚管理 Mapper
 *
 * @author AKai
 */
@Mapper
public interface RewardPunishRecordMapper extends BaseMapperX<RewardPunishRecordDO> {

    default PageResult<RewardPunishRecordDO> selectPage(RewardPunishRecordPageReqVO reqVO) {
        return selectPageForJoin(reqVO, RewardPunishRecordDO.class,new MPJLambdaWrapperX<RewardPunishRecordDO>()
                .eqIfPresent(RewardPunishRecordDO::getSchoolYear, reqVO.getSchoolYear())
                .eqIfPresent(RewardPunishRecordDO::getSemester, reqVO.getSemester())
                .leftJoin(StudentRollDO.class,StudentRollDO::getId,RewardPunishRecordDO::getStudentId)
                .leftJoin(CollegesDO.class,CollegesDO::getId,StudentRollDO::getCollegesId)
                .leftJoin(ClassesDO.class,ClassesDO::getId,StudentRollDO::getClassesId)
                .selectAll(RewardPunishRecordDO.class)
                .selectAs(StudentRollDO::getStudentName,RewardPunishRecordDO::getStudentName)
                .selectAs(StudentRollDO::getStudentNumber,RewardPunishRecordDO::getStudentNumber)
                .selectAs(CollegesDO::getCollegeName,RewardPunishRecordDO::getCollegeName)
                .selectAs(ClassesDO::getClassesName,RewardPunishRecordDO::getClassesName)
                .orderByDesc(RewardPunishRecordDO::getId));
    }

    default List<RewardPunishRecordDO> selectList(RewardPunishRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RewardPunishRecordDO>()
                .eqIfPresent(RewardPunishRecordDO::getSchoolYear, reqVO.getSchoolYear())
                .eqIfPresent(RewardPunishRecordDO::getSemester, reqVO.getSemester())
                .orderByDesc(RewardPunishRecordDO::getId));
    }

}
